import operate from '@dfeidao/atom-nodejs/db/operate';
// import insert from '@feidao/web/atom/nodejs/db/insert';
// import { IBaseTable } from '@feidao/web/atom/nodejs/db/interfaces';


interface Message {
	_id: string;
	usercode: string;
	role_no: string;
	pk_val: string;
	search_field_val: string;
	create_time: number;
	productid: string;
}

export default async function atom(msg: Message, action_id: string, session_id: string, spaceid: string) {
	const systemid = '12';
	const { exec, update } = operate(action_id, session_id, systemid);
	update('pub_user_connect', { _id: msg._id }, {
		_id: msg._id,
		usercode: msg.usercode,
		role_no: msg.role_no,
		pk_val: msg.pk_val,
		search_field_val: msg.search_field_val,
		create_time: msg.create_time,
		productid: msg.productid
	});
	const ret = await exec();
	if (ret.code === 1) {
		return 'success';
	} else {
		return 'fail';
	}
}
